/*
 * @Author: fisher
 * @Date: 2024-02-06 18:29:23
 * @LastEditors: fisher luthor-li@qq.com
 * @LastEditTime: 2024-02-06 19:09:48
 * @FilePath: \allback\middlewares\loggingMiddleware.js
 * @Description:
 */
// loggingMiddleware.js
const logger = require('../utils/logger') // 确保路径匹配您的项目结构
async function loggingMiddleware(ctx, next) {
  const start = Date.now() // 请求开始时间
  await next() // 执行下一个中间件
  const ms = Date.now() - start // 计算持续时间
  logger.info(`${ctx.method} ${ctx.url} - ${ms}ms`) // 记录请求日志
}
module.exports = loggingMiddleware // 导出此中间件供应用使用
